<?php
	header('Content-Type:text/html;Charset=utf-8');
	header("Access-Control-Allow-Origin:*");
	header("Access-Control-Allow-Methods:GET,POST");
	//将拿到的数据提交给数据库
	//(1)连接process数据库
	$conn=mysqli_connect('localhost:3306','root','sdo2605587','process');
	//为数据库指定字符集
	if (mysqli_connect_error()) {
    die("数据库连接失败: " . mysqli_connect_error());
	}
	mysqli_query($conn,'SET NAMES utf8');

	//发送SQL语句
	$sql="SELECT dno,name,life,score,level,pClass FROM fly ORDER BY score DESC";
	//(3)执行SQL
	$result = mysqli_query($conn, $sql);
	$arr=array();
	for($i=0;$i<5;$i++){
		$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
		$arr[] = $row;		
	};
	echo json_encode($arr);//转化为json对象
?>